package com.vlin.scene.command.tuya;

import com.vlin.entity.scene.Command;
import com.vlin.scene.actuator.AbstractCommandHandler;
import com.vlin.scene.command.TuyaCommand;
import com.vlin.service.tuya.TuyaService;

public class TuyaCommandHandler extends AbstractCommandHandler {

	private TuyaService tuyaService;
	
	public TuyaCommandHandler(TuyaService tuyaService) {
		this.tuyaService = tuyaService;
	}
	
	@Override
	public boolean doSupport(Command command) {
		
		return TuyaCommand.class.isAssignableFrom(command.getClass()) && command.getType() == 1;
	}

	@Override
	public void doHandle(Command command) {
		TuyaCommand tuyaCommand = (TuyaCommand) command;
		if(tuyaService != null) {
			tuyaService.sendCommonds(tuyaCommand.getDid(), tuyaCommand.getCommands().toString());
		}
		 
	}

	public TuyaService getTuyaService() {
		return tuyaService;
	}

	public void setTuyaService(TuyaService tuyaService) {
		this.tuyaService = tuyaService;
	}
	
}
